home *** CD-ROM | disk | FTP | other *** search
- /****
- * CIntelligentDecorator.c
- *
- * This class makes the Decorator a little more intelligent.
- *
- * Copyright © 1993 Quipus, by Mårten Sörliden. All rights reserved.
- *
- ****/
-
- #include <Constants.h>
- #include <CDesktop.h>
- #include <CList.h>
- #include <CIntelligentDecorator.h>
- #include <CIntelligentWindow.h>
-
-
- /*** Global Variables ***/
-
- extern CDesktop *gDesktop;
-
-
- /** Construction and destruction methods **/
-
- void CIntelligentDecorator::IIntelligentDecorator()
- {
- IDecorator();
- SetFirstLocation();
- }
-
- void CIntelligentDecorator::Dispose(void)
- {
-
- inherited::Dispose();
- }
-
-
- /** Accessing methods **/
-
- short CIntelligentDecorator::GetWNum()
- {
- CList *theWindows;
- long n, i;
- CObject *theObject;
- CIntelligentWindow *theWindow;
- Str255 theTitle;
- short theCount, tempCount;
-
- theCount = 1;
- theWindows = gDesktop->itsWindows;
- n = theWindows->GetNumItems();
- for (i = 1; i <= n; i++) {
- theObject = theWindows->NthItem(i);
- if (member(theObject, CIntelligentWindow)) {
- theWindow = (CIntelligentWindow *)theObject;
- tempCount = theWindow->GetWNum();
- if (tempCount >= theCount)
- theCount = tempCount + 1;
- }
- }
- return(theCount);
- }
-
-
- /** Window methods **/
-
- void CIntelligentDecorator::SetFirstLocation()
- {
- hLocation = LEFT_SMARGIN - 1;
- vLocation = TOP_SMARGIN + GetMBarHeight() - 1;
- }
-
- // Override
- void CIntelligentDecorator::PlaceNewWindow(CWindow *theWindow)
- {
- if (member(theWindow, CIntelligentWindow))
- theWindow->Zoom(inZoomOut);
- StaggerWindow(theWindow);
- if (!member(theWindow, CIntelligentWindow))
- theWindow->ChangeSize(wWidth, wHeight);
- }
-
- // Override
- void CIntelligentDecorator::StaggerWindow(CWindow *theWindow)
- {
- inherited::StaggerWindow(theWindow);
- if (index == 1)
- SetFirstLocation();
- }